import json

from flask import Blueprint, request
from utils.Response import Response

addFriend_bp = Blueprint('addFriend_bp', import_name=__name__, url_prefix='/addFriend')


@addFriend_bp.get("")
def get_friendList():
    with open("data/user_list.txt", 'r', encoding='utf-8') as file:
        conversations = file.read()  # 读取整个文件内容为一个长字符串
    userlist=json.loads("[" + conversations + "]")
    new_id = str(int(userlist[-1]['id']) +1)
    with open("data/user_list.txt", 'a', encoding='utf-8') as file:
        file.write(',{"id":"'+new_id+'"}')
    return Response.success(data=new_id)